#ifndef SHIP_H_
#define SHIP_H_

#include "../WidgetMovimiento.h"
#include "../WidgetSonido.h"
#include "../Event.h"
#include "ShipStatus.h"
#include "../Timer.h"
#include "bonus/Bonus.h"
#include "UserEquipment.h"
#include "Base.h"
#include "Laser.h"
#include "../../common/DTOShipAction.h"

class Ship: public WidgetMovimiento, WidgetSonido {

private:
	std::string owner;
	std::string imagePath;
	float rotationVelocity;
	int maximumVelocity;
	int propulsion;
	int friction;
	int bulletLifeTime;

	float velX;
	float velY;
	float nextVelX;
	float nextVelY;

	bool goingForward;
	bool turningLeft;
	bool turningRight;
	bool shooting;
	bool keyPressed;

	bool isHealing;

	//User base.
	Base* base;

	Timer timer;
	Timer timer_inmune;

	SDL_Surface* burstOnSurface;
	SDL_Surface* burstOffSurface;

    //Son los bonus que tiene la nava
    UserEquipment *userEquipment;

    bool isDead();
    void loadOtherImageFiles();
    void initUserInfo();
public:
    Ship(ShipStatus *shipStatus, Widget *parent, bool duenoInstancia, bool esAdmin);
    virtual void handleEvent(Event event);
    virtual void handleColision(WidgetMovimiento *with);
    virtual void handleBonus(Bonus *bonus);
    virtual void resolve();
    virtual void showOn(SDL_Surface *surface);
    ShipStatus* getShipStatus();
    DTOShipAction* getDieDTO();
    DTOShipAction* getLifeReduceDTO(int lifeReduce,playElement element);
    DTOShipAction* getReturnDTO(int x, int y);
    void updateStatus(ShipStatus *toUse);
    std::string getOwner();
    int getBulletAngle();
    bool isShooting();
    bool duenoesinstancialocal;
    UserEquipment *getUserEquipment() const;
    int getBulletLifeTime();
    virtual ~Ship();

    int getFrontAmmoX();
    int getFrontAmmoY();

    int getBackAmmoX();
    int getBackAmmoY();

    void reduceLife(int value,playElement element);
    void die();
    void resetShipInstance(int x, int y);
};

#endif /* Ship_H_ */
